<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        //es6 class
        class Person {
            name
            constructor(name) {
                this.name = name
            }
            sayHi() {
                console.log(`父类`)
            }
        }

        // const p1 = new Person('jack')
        // console.log(p1)
        // console.log(p1.name)
        // p1.sayHi()
        
        class Student extends Person {
            age // 声明一个属性 
            constructor(name, age) {
                super(name) // 调用父类的构造函数
                this.age = age
            }
            sayHello() {
                console.log(`子类`)
            }
        }

        const s = new Student('tom',18)
    </script>
</body>

</html>